//教学满意度
Page({
  data: {
    snoValue: '',
    nameValue: '',
    sexValue: 2,
    skillsValue: [],
    skillsName: [],
    statificationValue: 0,
    opinionValue: "",
    avgStatification: 0
  },
  onClickLeft() {
    wx.navigateBack({
      delta: 1,
    })
  },
  onLoad: function () {
    var that = this;
    wx.request({
      url: 'https://hello-cloudbase-3gw8f5h0ac31340e-1259504677.ap-guangzhou.app.tcloudbase.com/container-applet-v/sampledata',
      success(res) {
        console.log(res.data)
        that.setData({
          snoValue: res.data.sno,
          nameValue: res.data.name,
          sexValue: String(res.data.gender),
          skillsName: res.data.skills,
          // statificationValue: res.data.statification,
          opinionValue: res.data.opinion,
          avgStatification: res.data.statification
        });
      },
      fail(e) {
        wx.showToast({
          icon: "error",
          title: e.errMsg,
        })
      }
    })
  },

  submit(e) {
    var that = this;
    console.log("提交")
    console.log(e.detail.value, this.data.statificationValue)
    wx.request({
      method: 'POST',
      data: e.detail.value,
      url: 'https://hello-cloudbase-3gw8f5h0ac31340e-1259504677.ap-guangzhou.app.tcloudbase.com/container-applet-v/sampledata',
      success(res) {
        that.onLoad()
        that.setData({
          statificationValue: 0
        })
      },
      fail(e) {
        console.log("连接服务器失败")
      }
    })
  },


  //复选框事件
  checkboxChange(event) {
    //console.log(event)
    this.setData({
      skillsValue: (event.detail),
    });
  },

  //滑动条事件
  statificationChange(event) {
    this.setData({
      statificationValue: event.detail.value,
    });
  }
})